# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=opus

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1
pkgrel=2
pkgdesc="Codec designed for interactive speech and audio transmission over the Internet (mingw-w64)"
arch=('any')
url="http://www.opus-codec.org/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=('strip' 'staticlibs')
source=("http://downloads.us.xiph.org/releases/${_realname}/${_realname}-${pkgver}.tar.gz"
    0001-correctly-detect-alloca.mingw.patch)
md5sums=('c5a8cf7c0b066759542bc4ca46817ac6'
         '006d3e2769d82904837b95abc20d196a')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/0001-correctly-detect-alloca.mingw.patch"
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-custom-modes \
    --disable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  # Install license
  #install -m644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
